package com.culturalCenter.dataCenter.mapper.user;

import com.culturalCenter.dataCenter.customEntity.user.CustomUserLocation;
import com.culturalCenter.dataCenter.entity.user.UserLocation;
import com.culturalCenter.dataCenter.entity.user.UserLocationCount;
import com.culturalCenter.dataCenter.entity.user.UserLocationTypeCount;
import com.culturalCenter.dataCenter.mapper.base.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface UserLocationMapper extends BaseMapper<UserLocation> {

    /**
     * 通过用户id查询
     *
     * @param userId 用户id
     *
     * @return
     */
    List<UserLocation> queryByUserId(@Param("userId") String userId);

    /**
     * 查询当前页需要的日期
     *
     * @param userId
     * @param offset
     * @param pageSize
     *
     * @return
     */
    List<String> findDateList(@Param("userId") String userId, @Param("offset") int offset, @Param("pageSize") int pageSize);

    /**
     * 根据用户和日期查询
     *
     * @param userId
     * @param date
     *
     * @return
     */
//    @Results({@Result(column = "id", property = "pictureList", many = @Many(select = "com.culturalCenter.dataCenter.mapper.user.PictureMapper.queryURLByUserId", fetchType = FetchType.EAGER))})
    List<CustomUserLocation> findListByUserAndDate(@Param("userId") String userId, @Param("date") String date);

    long findDateCount();

    /**
     * 批量插入
     *
     * @param userLocationList
     */
    void insertBatch(List<UserLocation> userLocationList);

    /**
     * 根据定位类型分组统计数量
     *
     * @return
     */
    List<UserLocationTypeCount> countLocationType();

    /**
     * 根据位置统计
     *
     * @return
     */
    List<UserLocationCount> countLocation();

}
